<!DOCTYPE html>
<html lang="en">
	<head>
		<include file="Index/head" />
	</head>

	<body>
		<include file="Index/header" />

		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>

			<div class="main-container-inner">
				<a class="menu-toggler" id="menu-toggler" href="#">
					<span class="menu-text"></span>
				</a>

				<include file="Index/menu" />
				
				<div class="main-content">
					<include file="Index/nav" />

					<div class="page-content">
						
							<!-- /**
							 * 右侧页面begin
							 */ -->
								<div class="row">
									<div class="col-xs-12">
										<div class="table-header">
											分组管理
										</div>

										<div class="table-responsive">
											<div id="sample-table-2_wrapper" class="dataTables_wrapper" role="grid">
											<div class="row">
											<div class="col-sm-6">
											<div id="sample-table-2_length" class="dataTables_length">
											</div>
											</div>
										<!-- 	<div class="col-sm-6" style="margin-bottom:-20px;">
											<div class="dataTables_filter" id="sample-table-2_filter">
											<label>搜索: <input type="text" aria-controls="sample-table-2">
											</label>
											</div>
											</div> -->
											<div class="col-sm-12"><div id="sample-table-2_length" class="dataTables_length"><label>组名:<input type="text" name="name" id="name" /></label><button id="add_group" class="btn btn-xs btn-primary">添加</button></div></div>
											</div>
											<table id="sample-table-2" class="table table-striped table-bordered table-hover dataTable" aria-describedby="sample-table-2_info" >
												<thead>
													<tr role="row">
													<th  role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Domain: activate to sort column ascending" style="width: 100px;">ID</th>
													<th role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Price: activate to sort column ascending" style="width: 183px;">组名(点击查看该组下所有用户)</th>
														<th class="" role="columnheader" tabindex="0" aria-controls="sample-table-2" rowspan="1" colspan="1" aria-label="Update: activate to sort column ascending" style="width: 294px;">
															<i class="icon-time bigger-110 hidden-480"></i>
															创建时间
														</th>
														<th class="sorting_disabled" role="columnheader" rowspan="1" colspan="1" aria-label="" style="width: 259px;">
															<i class="icon-time bigger-110 hidden-480"></i>
															管理
														</th></tr>
												</thead>
						
											<!-- <tbody role="alert" aria-live="polite" aria-relevant="all"> -->
											<volist name="list" id="vo">
											<tr class="odd">
											
												<td class=" ">{$vo.id}</td>
												<!-- <input type="text" id="modify_id" hidden="hidden" value="{$vo.id}" /> -->
												<td class=" "><a href="{:U('Admin/User/members_group_user',array('gid' => $vo['id']))}">{$vo.name}</a></td>
												<td class="hidden-480 ">
													<span class="label label-sm label-warning">{$vo.ctime|date="Y-m-d H:i:s",###}</span>
												</td>
												<td class=" ">
													<div class="visible-md visible-lg hidden-sm hidden-xs action-buttons">
														<a class="green bootbox-regular" href="#" id="{$vo.id}" idname="{$vo.name}">
															<i class="icon-pencil bigger-130" title="修改"></i>
														</a>
														<a class="red" href="javascript:del_group({$vo.id})">
															<i class="icon-trash bigger-130" title="删除" ></i>
														</a>
													</div>

													<div class="visible-xs visible-sm hidden-md hidden-lg">
														<div class="inline position-relative">
															<button class="btn btn-minier btn-yellow dropdown-toggle" data-toggle="dropdown">
																<i class="icon-caret-down icon-only bigger-120"></i>
															</button>

															<ul class="dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close">

																<li>
																	<a href="#" class="tooltip-success" data-rel="tooltip" title="" data-original-title="Edit">
																		<span class="green">
																			<i class="icon-edit bigger-120"></i>
																		</span>
																	</a>
																</li>

																<li>
																	<a href="#" class="tooltip-error" data-rel="tooltip" title="" data-original-title="Delete">
																		<span class="red">
																			<i class="icon-trash bigger-120"></i>
																		</span>
																	</a>
																</li>
															</ul>
														</div>
													</div>
												</td>
											</tr>
											</volist>
											</tbody>
											</table>
												<div class="row">
													<div class="col-sm-6">
														<div class="dataTables_info" id="sample-table-2_info">Showing 1 to 10 of 23 entries</div>
													</div>
													<div class="col-sm-6">
														<div class="dataTables_paginate paging_bootstrap">
															<ul class="pagination">
																{$page}
															</ul>
														</div>
													</div>
												</div>
										</div>
									</div>
								</div>
							<!-- /**
							 * 右侧页面end
							 */ -->
					</div><!-- /.page-content -->
				</div>

			</div><!-- /.main-container-inner -->

			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="icon-double-angle-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->

		<include file="Index/footer" />
		<script src="__PUBLIC__/assets/js/bootbox.min.js"></script>
		<script src="__PUBLIC__/assets/js/jquery.easy-pie-chart.min.js"></script>
		<script>
		// ajax 删除分组
		function del_group(id){
			var r= confirm('确定删除该分组?');
			if(r){
				var url = "{:U('Admin/User/del_group')}";
				var id = id;
				$.ajax({
					type:'post',
					url:url,
					data:{id:id},
					dataType:'json',
					success:function(data){
						if(data==1){
							window.location.href="{:U('Admin/User/group_lists')}";
						}else{
							alert('删除失败!');
						}
					}
				});

			}else{
				return false;
			}
		}

		//ajax 添加新分组
		$(document).ready(function(){
			$("#add_group").click(function(){
				var name = $("#name").val();
				var url = "{:U('Admin/User/add_group')}";
				$.ajax({
					type:'post',
					url:url,
					data:{name:name},
					dataType:'json',
					success:function(data){
						if(data==1){
							alert('添加成功!');
							window.location.href='{:U("Admin/User/group_lists")}';
						}else{

							alert('添加失败!');
						}
					}
				});
			});


			$(".bootbox-regular").click(function() {
				var id = $(this).attr('id');
				var idname = $(this).attr('idname');
				bootbox.prompt({
		            title: "填写新的组名",
		            value: idname,
		            callback: function(result) {
		                if (result === null) {
		                } else {
		                	var name = result;
		                	var url = "{:U('Admin/User/modify')}"
		                	$.ajax({
		                		type:'post',
		                		url:url,
		                		data:{name:name,id:id},
		                		dataType:'json',
		                		success:function(data){
		                			if(data==1){
		                				window.location.href="{:U("Admin/User/group_lists")}";
		                			}
		                		}
		                	});
		                }
		            }
		        }); 
			});
		});

		</script>
	</body>
</html>
